<template>
	<view class="detail-content" v-if="canshow">
		<!-- 价格 -->
		<view class="content-price bar">
			<text style="color: red;">¥</text>
			<text style="color: red;font-size: 48rpx;font-weight: bold;">{{goods.packages[nowSelectPackageIndex].price}}</text>
		</view>
		<!-- 标题 -->
		<view class="content-title bar" style="height: 100rpx;">{{goods.title}}</view>
		<!-- 发货 -->
		<view class="content-bar-shipping bar">
			<view class="bar-title">发货</view>
			<view class="bar-shipping-address">
				<uni-icons type="location" :size="22" color="#888888;"></uni-icons>
				<view>{{goods.shipping_address}}</view>
			</view>
			<view style="width: 4rpx;margin: 20rpx 0rpx 20rpx 0rpx;background-color: #Ccc;"></view>
			<view class="bar-shipping-price">快递：
				<view>{{goods.shipping_price}}</view>
				元
			</view>
			<view class="bar-shipping-sale">
				月销{{goods.sale_num}}
			</view>
		</view>
		<!-- 选择套餐 -->
		<view class="content-bar-select bar" @click="popSelect">
			<view class="bar-title">选择套餐</view>
			<view class="bar-select-title">{{goods.packages[nowSelectPackageIndex].title}}</view>
			<uni-icons type="arrowright" size="18" class="right-arrow"></uni-icons>
		</view>
		<!-- 参数 -->
		<view class="content-bar-parameter bar" @click="popParameter">
			<view class="bar-title">参数</view>
			<uni-icons type="arrowright" size="18" class="right-arrow"></uni-icons>
		</view>
		<!-- 评论 -->
		<view @click="toCommentPage" class="content-bar-comments bar">
			<view class="bar-title">评论列表</view>
			<uni-icons type="arrowright" size="18" class="right-arrow"></uni-icons>
		</view>
		<!-- 店铺信息 -->
		<store-info-card :storeId="storeId" class="store-info-card"></store-info-card>
	</view>
</template>

<script>
	export default {
		props: {
			goodsId: {
				type: Number,
				default:0
			},
			nowSelectPackageIndex: {
				type: Number,
				default: 0
			}
		},
		name: "goods-deail-bars",
		data() {
			return {
				goods:{},
				canshow:false,
				storeId:0
			};
		},
		created() {
			var vue = this
			vue.canshow = false
			vue.$request("goods/get",{id:vue.goodsId},function(res){
				vue.goods = vue.$fixGoods(res.data.data)[0]
				vue.storeId = parseInt(vue.goods.storeId)
				//console.log(vue.goods);
				vue.canshow = true
			})
		},
		methods: {
			popSelect() {
				this.$emit("popSelect")
			},
			popParameter() {
				this.$emit("popParameter")
			},
			toCommentPage() {
				uni.navigateTo({
					url: "/pages/goods-detail-comment/goods-detail-comment?id=" + this.goods.id
				})
			},
		}
	}
</script>

<style lang="scss">
	.detail-content {
		border-top: 2rpx #e3e3e3 solid;
		display: flex;
		flex-direction: column;
		border-radius: 30rpx 30rpx 0rpx 0rpx;
		position: relative;
		top: -30rpx;
		background-color: #fff;

		.content-price {
			margin-top: 30rpx;
		}


		.content-title {
			border-bottom: 20rpx #e5e5e5 solid;
			font-size: 36rpx;
			font-weight: bold;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			text-overflow: ellipsis;
			overflow: hidden;
			display: -webkit-box;
		}

		.content-bar-shipping {
			display: flex;
			flex-direction: row;
			align-items: center;
			position: relative;

			.bar-shipping-address {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-left: 20rpx;
				
				view{
					color: #888888;
					font-size: 28rpx;
				}
			}

			.bar-shipping-price {
				display: flex;
				color: #888888;
				font-size: 32rpx;
				flex-direction: row;
				align-items: center;
				margin-left: 20rpx;
			}

			.bar-shipping-sale {
				position: absolute;
				right: 10rpx;
				color: #888888;
				font-size: 32rpx;
			}
		}

		.content-bar-select {
			display: flex;
			flex-direction: row;
			align-items: center;
			position: relative;

			.bar-select-title {
				margin-left: 20rpx;
				color: #dddddd;
				width: 400rpx;
				overflow: hidden;
				font-size: 28rpx;
			}
		}

		.content-bar-parameter {
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		.content-bar-comments {
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		.store-info-card {
			margin-top: 20rpx;
		}

		.bar {
			height: 80rpx;
			padding: 0rpx 20rpx 0rpx 20rpx;
		}

		.bar-title {
			color: #888888;
			font-size: 32rpx;
		}

		.right-arrow {
			position: absolute;
			right: 10rpx;
		}
	}
</style>
